var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    Temp: true,
    FullName:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      openid: app.globalData.openid,
      name: app.globalData.name,
      //name: '侯志喜',
      typename: app.globalData.TypeName,
    })
    //this.getDate();
  },

  getDate: function () {
    var that = this;
    console.log(that.data.FullName);
    wx.cloud.callFunction({
      name: 'GetPost',
      data: {
        data: "fun=8&QueryStr=" + that.data.name + "&QueryStr1="+this.data.FullName
      },
      success: res => {
        console.log(res);
        let obj = JSON.parse(res.result)
        console.log(obj.length);
        if (obj.length>0){
        that.setData({ list: obj,Temp:false})
        }else{
          wx.showToast({
            icon: 'none',
            title: '没有找到相关的客户',
          })
        }
      },
      fail: err => {
        wx.showToast({
          icon: 'none',
          title: '调用失败',
        })
      }
    })
  },
  Backpage: function (e) {    
    let FullName=e.currentTarget.dataset.fullname,
     ctypeid=e.currentTarget.dataset.id;
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];    
    prevPage.setData({
      mydata: {
        id: ctypeid,
        FullName: FullName
      }
    })
    wx.navigateBack({//返回
      delta: 1
    })
  },
  Form:function(data){
     let name= data.detail.value.caption; 
     this.setData({FullName:name});       
     this.getDate();
  }
})